package jmine.tec.purge;

import java.util.List;

import jmine.tec.purge.api.PurgeHelper;
import jmine.tec.purge.api.Purger;
import bancosys.tec.persist.dao.BaseDAO;
import bancosys.tec.persist.entities.domain.Agente;
import bancosys.tec.utils.date.Date;

/**
 * @author Marcio Ribeiro (mmr)
 * @created Aug 12, 2011
 */
public class AgentePurger extends BaseDAO<Agente> implements Purger {

    /**
     * {@inheritDoc}
     */
    public int purge(Date maxDate, int maxWindowSize) {
        List<Long> ids = PurgeHelper.getIds(createCriteria(), "birthDate", maxDate, maxWindowSize, false);
        return getSession().createQuery(PurgeHelper.createDeleteQuery("Agente", ids)).executeUpdate();
    }

    /**
     * {@inheritDoc}
     */
    public int countItemsToPurge(Date maxDate) {
        return PurgeHelper.countItemsToPurge(createCriteria(), "birthDate", maxDate, false);
    }
}
